using System;
using System.Web.Script.Serialization;
namespace CommandLib.Base
{
	public static class JsonHelper
	{
		private static readonly JavaScriptSerializer jss = new JavaScriptSerializer();
		public static string ToJson(this object source)
		{
			return source.ToJson(source.GetType());
		}
		public static string ToJson(this object source, Type type)
		{
			return JsonHelper.jss.Serialize(source);
		}
		public static T ParseJSON<T>(this string str)
		{
			return JsonHelper.jss.Deserialize<T>(str);
		}
		public static T DeepClone<T>(this object Source)
		{
			string str = Source.ToJson();
			return str.ParseJSON<T>();
		}
	}
}
